// Kony


#include "Checkpoint/MapEntrance.h"

#include "Game/Base_GameModeBase.h"
#include "Interaction/PlayerInterface.h"
#include "Kismet/GameplayStatics.h"

void AMapEntrance::LoadActor_Implementation()
{
	//在加载地图入口时 不执行任何操作，因为这个没有特效，除非以后需要增加特效在这里增加即可
}

//重写接口抽象类 设置高亮 - 这里重写是因为 地图入口需要任何时候选中都高亮
void AMapEntrance::HighlightActor_Implementation()
{
	CheckpointMesh->SetRenderCustomDepth(true);
}
//处理碰撞函数
void AMapEntrance::OnSphereOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
	if (OtherActor->Implements<UPlayerInterface>())
	{
		//设置发光变量为真 后续存档使用
		bReached = true;
		if (ABase_GameModeBase* BaseGM = Cast<ABase_GameModeBase>(UGameplayStatics::GetGameMode(this)))
		{
			//调用保存世界动态函数，传入目的地地图的资源名称 用于保存目的地地图
			BaseGM->SaveWorldState(GetWorld(), DestinationMap.ToSoftObjectPath().GetAssetName());
		}
		//保存玩家存档点
		IPlayerInterface::Execute_SaveProgress(OtherActor, DestinationPlayerStartTag);
	}
}

